import Vue from 'vue';
import App from './App.vue';
import elementUI, { Message } from 'element-ui';
import events from './events';
import { router, addAsyncRoutes } from './router';
import userRoutes from "./router/userRoutes";
import store from "./store";
import plugin from "./plugins";
import { getCookie } from './plugins/utils';
import filters from './filters';
import axios from './axios';
import qs from 'qs';

import 'element-ui/lib/theme-chalk/index.css';
import '@/static/style/main.scss';

Vue.use(elementUI);
Vue.use(plugin);

Vue.config.productionTip = false;
Vue.prototype.$emitter = events;
Vue.prototype.$axios = axios;
Vue.prototype.$qs = qs;
Vue.prototype.$message = Message;

// console.log(process.env);

// 检测本地是否有localstorage，存储用户路由权限列表
if(getCookie('USER_TOKEN')){
  addAsyncRoutes(router, userRoutes)
}

// 全局mixin混入
Vue.mixin({
  filters
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app');
